/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aufgabe02a;

import java.sql.*;

/**
 *
 * @author Dennis Wittkoetter
 */
public class main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] s) throws SQLException {
        DriverManager.registerDriver(
        new org.apache.derby.jdbc.ClientDriver());
        
        try (Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/Hochschule","dennis", "123")) {
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(
                      "SELECT ModulNr, COUNT(*) "
                    + "FROM Hoert "
                    + "GROUP BY ModulNr"
                    );
            
            while (rs.next()) {
                System.out.println(rs.getString(1)+" "+rs.getString(2));
            }
        }
    }
}
